Skip to content

[Studio] Implement format utility functions - #660

Merged
lizhimins merged 2 commits into
apache:rocketmq-studiofrom
zhaohai666:pr-fe-02-format-utilities
Jul 31, 2026
Merged

[Studio] Implement format utility functions#660
lizhimins merged 2 commits into
apache:rocketmq-studiofrom
zhaohai666:pr-fe-02-format-utilities

Conversation

@zhaohai666

Copy link
Copy Markdown

Summary

Replace TODO stub implementations in format.ts with full-featured utility
functions used across the dashboard.

  • formatDateTime(date): Format to 'YYYY-MM-DD HH:mm:ss' with proper padding
  • formatDate(date): Format to 'YYYY-MM-DD' (was a TODO returning raw string)
  • formatBytes(bytes, decimals?): Human-readable 1024-based formatting
    (was a TODO returning raw 'X B'), handles zero and negative values
  • formatNumber(num): Thousands separator formatting (e.g. 1234567 → '1,234,567')
  • formatDelay(seconds, lang?): Duration formatting with i18n support
    (zh: "22小时55分钟", en: "22h 55m")
  • formatPercent(value, decimals?): Fixed-decimal percentage formatting

All functions are pure with no side effects, making them easy to test and reuse.

Test plan

  • Verify formatDateTime handles valid dates, invalid dates, and string input
  • Verify formatBytes: 0 → '0 B', 1536 → '1.5 KB', 1048576 → '1 MB'
  • Verify formatDelay: 82500 → '22小时55分钟' (zh), '22h 55m' (en)
  • Verify formatPercent: 99.5 → '99.5%'

…ay, percent)

Replace TODO stub implementations in format.ts with full-featured utilities:
- formatDateTime / formatDate: proper date formatting with padding
- formatBytes: human-readable 1024-based byte formatting
- formatNumber: thousands separator formatting
- formatDelay: duration formatting with i18n support (zh/en)
- formatPercent: fixed-decimal percentage formatting
Smooth cardinal-spline path, gradient area fill, glow on last-point dot,
configurable strokeWidth/showDot/animated, and responsive SVG mode.
The MiniBar zero-value change from the original PR is dropped: trunk
intentionally renders no visible bar at zero throughput (apache#629).
@lizhimins
lizhimins force-pushed the pr-fe-02-format-utilities branch from e1bcd6e to 8f14dd1 Compare July 31, 2026 08:08
@lizhimins
lizhimins merged commit 9921a0e into apache:rocketmq-studio Jul 31, 2026
3 checks passed
@zhaohai666
zhaohai666 deleted the pr-fe-02-format-utilities branch August 13, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants